feat(snowflake): add function calling support for Snowflake Cortex REST API #15221
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds function calling (tools) support for Snowflake Cortex REST API, enabling tool use with models like Claude 3.5 Sonnet.
Changes
Implementation (
litellm/llms/snowflake/chat/transformation.py)toolsandtool_choiceto supported OpenAI parameterstool_specformatcontent_list→ OpenAItool_callstool_choicetransformation to Snowflake's array formatTesting
tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py)tests/llm_translation/test_snowflake.py)Technical Details
Request Transformations
Tools:
OpenAI format → Snowflake tool_specTool Choice:
OpenAI nested → Snowflake arrayResponse Transformations
Parses Snowflake's unique format:
{ "content_list": [ {"type": "tool_use", "tool_use": {"tool_use_id": "...", "name": "...", "input": {...}}} ] }Converts to OpenAI format:
{ "content": "...", "tool_calls": [{"id": "...", "type": "function", "function": {"name": "...", "arguments": "..."}}] }Verification
Tested with real Snowflake Cortex API (account: XXXXXX):
tool_choice(forced tool use)completion()andresponses()APIsExample output:
Context
Test Plan
Unit tests (run automatically in CI):
Integration test (requires Snowflake credentials - marked as skip):
Breaking Changes
None - This is purely additive functionality.
🤖 Generated with Claude Code